package com.hyt.it.ogt.kq.service.bm.feign.sq;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.exception.exception.BusinessLogicException;
import com.hyt.it.ogt.kq.service.bm.feign.sq.model.OrganCandidateInfoVO;
import com.hyt.it.ogt.kq.service.bm.feign.sq.model.PtCandidateParamVO;
import com.hyt.it.ogt.kq.service.gov.model.dto.ExamSubjectDTO;
import com.hyt.model.PageParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SqClientHystrix implements FallbackFactory<SqClient> {

    @Override
    public SqClient create(Throwable cause) {
        log.error("授权服务熔断", cause);

        return new SqClient() {
            @Override
            public ApiResponse<PageParam<OrganCandidateInfoVO>> getByPage(PtCandidateParamVO ptCandidateParam) {
                log.error("#获取页查询考生信息失败，进入熔断");
                throw new BusinessLogicException(31212104, "获取页查询考生信息失败");
            }

            @Override
            public ApiResponse<ExamSubjectDTO> querySubjectById(String id) {
                log.error("#获取授权科目详情失败，进入熔断");
                throw new BusinessLogicException(31212105, "获取科目数据失败");
            }
        };
    }
}
